package io.renren.modules.task.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.task.model.ChinaDo;
import io.renren.modules.task.model.ChinaVo;
import io.renren.modules.task.service.ChinaService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2020-11-21 17:25:31
 */
@RestController
@RequestMapping("business/china")
public class ChinaController {
    @Autowired
    private ChinaService chinaService;


    /**
     * 列表
     */
    @RequestMapping("/list-tree")
    //@RequiresPermissions("generator:china:list")
    public R listTree() {
        List<Map<String, Object>> nodeTree = chinaService.getNodeTree();

        return R.ok().put("page", nodeTree);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:china:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = chinaService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/listAll")
//    @RequiresPermissions("generator:china:list")
    public R listAll(@RequestParam Map<String, Object> params) {
        List<ChinaVo> listAll = chinaService.queryList();

        return R.ok().put("page", listAll);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:china:info")
    public R info(@PathVariable("id") Integer id) {
//      ChinaEntity china = chinaService.getById(id);

        return R.ok().put("china", "china");
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:china:save")
    public R save(@RequestBody ChinaDo china) {
        //chinaService.save(china);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:china:update")
    public R update(@RequestBody ChinaDo china) {
        //chinaService.updateById(china);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:china:delete")
    public R delete(@RequestBody Integer[] ids) {
        //chinaService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
